#ifndef _LIGHTCLASS_H_
#define _LIGHTCLASS_H_

#include <d3dx10math.h>

static const int MAX_NUM_LIGHTS = 20;

enum COSTANTBUFFER
{
	LIGHT_CB_POSITION		= 0,
	MATERIAL_CB_POSITION	= 1,
};

class LightClass
{
public:
	//LightClass();

	void SetDiffuseColor(float, float, float, float);
	void SetAmbientColor(float, float, float, float);
	void SetPosition	(float, float, float);
	void SetDirection	(float, float, float);

	const D3DXVECTOR4& GetDiffuseColor() const;
	const D3DXVECTOR4& GetDirection() const;
	const D3DXVECTOR4& GetAmbientColor() const;
	const D3DXVECTOR4& GetPosition() const;

private:

	D3DXVECTOR4 m_position;
	D3DXVECTOR4 m_diffuseColor;
	D3DXVECTOR4 m_ambientColor;
	D3DXVECTOR4 m_direction;

};

struct LightBufferType
{
	D3DXVECTOR4 m_positions		[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_diffuseColors	[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_ambientColors	[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_directions	[MAX_NUM_LIGHTS];
	float numlights;
	D3DXVECTOR3 padding;
};


struct LightsContainer
{
	LightsContainer()
	{
		numlights=0;
	};

	void AddLight(LightClass* i_light)
	{
		m_positions[numlights]=(i_light->GetPosition());
		m_diffuseColors[numlights]=(i_light->GetDiffuseColor());
		m_ambientColors[numlights]=(i_light->GetAmbientColor());
		m_directions[numlights]=(i_light->GetDirection());	
		++numlights;
	};

	int GetNumLights()
	{
		return numlights;
	};

	void CopyLightsToBuffer(LightBufferType* o_buffer)
	{
		for(int i = 0; i != numlights; ++i)
		{
			(*o_buffer).m_positions[i] = m_positions[i];
			(*o_buffer).m_diffuseColors[i] = m_diffuseColors[i];
			(*o_buffer).m_ambientColors[i] = m_ambientColors[i];
			(*o_buffer).m_directions[i] = m_directions[i];
		}
		(*o_buffer).numlights = numlights;
	}

	D3DXVECTOR4 m_positions		[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_diffuseColors	[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_ambientColors	[MAX_NUM_LIGHTS];
	D3DXVECTOR4 m_directions	[MAX_NUM_LIGHTS];
	int numlights;
};

#endif